﻿using System;
using System.Linq;
using VictorBlaga.DocumentManagement.Core.Models;
using VictorBlaga.DocumentManagement.Core.Models.Repositories;

namespace VictorBlaga.DocumentManagement.Tests.Stubs
{
    public class FakeUserRepository : IUserRepository
    {
        private readonly User[] _fakeUsers
            =
            {
                new User
                    {
                        Email = "test@email.com",
                        Firstname = "Gigi",
                        Lastname = "Duru",
                        ID = 1,
                        PasswordHash = "abcdefgh",
                        PasswordSalt = "sare",
                        UserLevel = 0,
                        Username = "slbtz",
                        Workshop = null
                    }
            };

        public User New()
        {
            return new User();
        }

        public User[] GetAll()
        {
            return _fakeUsers;
        }

        public User GetByID(int id)
        {
            return _fakeUsers.FirstOrDefault(u => u.ID == id);
        }

        public void Save(User item)
        {
            return;
        }

        public void Delete(User item)
        {
            return;
        }

        public bool IsUniqueUserName(int id, string username)
        {
            var user = _fakeUsers.FirstOrDefault(u => (u.Username.ToLower() == username.ToLower() && u.ID != id));
            return user == null;
        }

        public bool IsUniqueEmail(int id, string email)
        {
            var user = _fakeUsers.FirstOrDefault(u => (u.Email.ToLower() == email.ToLower() && u.ID != id));
            return user == null;
        }

        public User[] GetByUserLevel(int userLevel)
        {
            throw new NotImplementedException();
        }

        public User[] GetAvailableTeamManagers()
        {
            throw new NotImplementedException();
        }

        public User[] GetAvailableWorkshopManagers()
        {
            throw new NotImplementedException();
        }
    }
}